package com.sqkj.dao;

import com.sqkj.entity.UserCard;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface UserCardDao {
    @Select("select * from usercard where id = #{id}")
    @Results({
            @Result(column="userId",property="user",one=@One(
                    select="com.sqkj.dao.UserDao.findById",fetchType= FetchType.EAGER))
    })
    public UserCard findById(int id);
    @Select("select * from usercard ")
    public List<UserCard> findAll();
    @Select("select * from usercard where userId = #{userId}")
    public List<UserCard> findByUserId(int userId);
    @Insert("insert into usercard(userId,Job,Phone,email,ComName,UsComName,ComInfo,Address,type,tag,UserCardIcon) values(#{userId},#{Job},#{Phone},#{email},#{ComName},#{UserComName},#{ComInfo},#{Address},#{type},#{tag},#{UserCardIcon})")
    public int add(@Param("userId")int userId,@Param("Job")String Job,@Param("Phone")String Phone,@Param("email")String email,@Param("ComName")String ComName,@Param("UserComName")String UserComName,@Param("ComInfo")String ComInfo,@Param("Address")String Address,@Param("type")int type,@Param("tag")String tag, @Param("UserCardIcon")String UserCardIcon);
    @Delete("delete from usercard where id=#{id}")
    public int deleteById(int id );


}
